package log

import (
	"bytes"
	"encoding/json"
	"github.com/sirupsen/logrus"
)

var Logger = logrus.New()

func init() {
	Logger.Level = logrus.WarnLevel
	//Logger.Level = logrus.InfoLevel
}

func SetLevel(level string) {
	Logger.Level, _ = logrus.ParseLevel(level)
}

func FormatJson(v interface{}) string {

	var src, _ = json.Marshal(v)

	var dst bytes.Buffer
	_ = json.Indent(&dst, src, "", "    ")

	return dst.String()
}

func Debug(format string, args ...interface{}) {
	Logger.Debugf(format, args...)
}

func Info(format string, args ...interface{}) {
	Logger.Infof(format, args...)
}

func Warn(format string, args ...interface{}) {
	Logger.Warnf(format, args...)
}

func Error(format string, args ...interface{}) {
	Logger.Errorf(format, args...)
}
